<?php

require_once 'db.php';

class Keyword extends DB {//thua ke Db

    private $_table = 'keyworkds';

    /**
     * 
     * @return type string
     */
    public function select() {//phuong thuc
        $this->connects();
        $query = 'SELECT * FROM ' . $this->_table;
        $keywords = $this->query($query);
        return $keywords;
    }

    public function lenght() {
        $this->connects();
        $query = 'SELECT * FROM ' . $this->_table;
        $keywords = $this->query($query);
        foreach ($keywords as $list_keyword) {
            if (strlen($list_keyword['name']) >= 10) {
                echo $list_keyword['id'];
                echo $list_keyword['name'] . "<br>";
            }
        }
    }

    public function lenghts() {
        $this->connects();
        $query = 'SELECT * FROM ' . $this->_table . '
                  GROUP BY name
                  HAVING MAX(LENGTH(name)) >= 20';
        $keywords = $this->query($query);
        return $keywords;
    }

}